﻿using System;
using System.ServiceModel;
using Ayatta.Contract.Component;
using Ayatta.Contract.Domain;
using System.Collections.Generic;

namespace Ayatta.Contract
{
    [ServiceContract(Namespace = ServiceContract.Namespace)]
    public interface IPassportService : IService
    {
        #region User

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="o">用户</param>
        /// <returns></returns>
        [OperationContract]
        int CreateUser(User o);

        /// <summary>
        /// 修改昵称
        /// </summary>
        /// <param name="id">用户Id</param>
        /// <param name="nickName">昵称</param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateUserNickName(int id, string nickName);

        /// <summary>
        /// 更新用户Avatar
        /// </summary>
        /// <param name="id">用户Id</param>
        /// <param name="avatarUrl">AvatarUrl</param>
        /// <returns></returns>
        [OperationContract]
        bool UpdateUserAvatar(int id, string avatarUrl);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id">用户Id</param>
        /// <returns></returns>
        [OperationContract]
        bool DeleteUser(int id);

        [OperationContract]
        User GetUser(int id);

        [OperationContract(Name = "GetUserWidthDetails")]
        User GetUser(int id, bool inclProfile = false, bool inclExtra = false);

        [OperationContract(Name = "GetUserByUsername")]
        User GetUser(string username);

        [OperationContract(Name = "GetUserByUsernamePassword")]
        User GetUser(string name, string password);

        [OperationContract]
        User GetUserByMobile(string mobile);

        [OperationContract]
        PagedList<User> GetPagedUsers(int index = 1, int size = 20, int? id = null, string guid = null, string name = null, bool? status = null);

        [OperationContract]
        bool ExistUserGuid(Guid guid);

        [OperationContract]
        bool ExistUserName(string username);

        [OperationContract]
        bool ExistBindingEmail(string email);

        [OperationContract]
        bool ExistBindingMobile(string mobile);

        [OperationContract]
        bool EmailBinding(int userId, string email);

        [OperationContract]
        bool MobileBinding(int userId, string mobile);

        [OperationContract]
        bool ChangePassword(int userId, string newPassword);

        //[OperationContract(Name = "ChangePasswordByEmail")]
        //bool ChangePassword(string email, string newPassword);

        [OperationContract]
        UserProfile GetUserProfile(int id);

        [OperationContract]
        bool UpdateUserProfile(UserProfile o);

        /// <summary>
        /// 更新最后一次登录信息
        /// </summary>
        /// <param name="id">用户Id</param>
        /// <param name="ip">最后一次登录Ip</param>
        [OperationContract]
        void UpdateUserLastLoginInfo(int id, string ip);

        [OperationContract]
        OAuthConfig GetOAuthConfig(int id);

        [OperationContract]
        IList<OAuthConfig> GetOAuthConfigs(bool? status = null);

        [OperationContract]
        void ExternalLogin(ExternalUser o);

        [OperationContract]
        UserExtra GetUserExtra(int id);
        #endregion

        #region UserAddress

        [OperationContract]
        UserAddress GetUserAddress(int id, int? userId = null);

        [OperationContract]
        IList<UserAddress> GetUserAddresses(int userId);

        [OperationContract]
        bool CreateUserAddress(UserAddress address);

        [OperationContract]
        bool UpdateUserAddress(UserAddress address);

        [OperationContract]
        bool DeleteUserAddress(int id, int? userId = null);

        [OperationContract]
        bool SetDefaultUserAddress(int id, int userId, AddressCategory category);

        #endregion

        #region UserInvoice

        [OperationContract]
        UserInvoice GetUserInvoice(int id, int? userId = null);

        [OperationContract]
        IList<UserInvoice> GetUserInvoices(int userId);

        [OperationContract]
        bool CreateUserInvoice(UserInvoice address);

        [OperationContract]
        bool UpdateUserInvoice(UserInvoice address);

        [OperationContract]
        bool DeleteUserInvoice(int id, int? userId = null);

        [OperationContract]
        bool SetDefaultUserInvoice(int id, int userId);

        #endregion
    }
}